﻿using Microsoft.VisualStudio.PlatformUI;
using System;

namespace Sasa.QualityTools.CodeAnalysis.FxCopIntegrator.UI
{
    public partial class CodeAnalysisConfigurationEditorWindow : DialogWindow
    {
        public CodeAnalysisConfigurationEditorWindow()
        {
            InitializeComponent();
        }


        //private void InitializeOptionItems()
        //{
        //    RuleSetOptionItems = new ObservableCollection<RuleSetOptionItem>();

        //    RuleSetOptionItems.Add(new RuleSetOptionItem { Name = "<None>" });

        //    var dir = Path.Combine(Path.GetDirectoryName(GetType().Assembly.Location), "RuleSets");
        //    foreach (var path in Directory.GetFiles(dir, "*.ruleset"))
        //    {
        //        AddOptionItem(path, false);
        //    }
        //}

        //private void AddOptionItem(string path, bool isCustom)
        //{
        //    try
        //    {
        //        var document = new XmlDocument();
        //        document.Load(path);
        //        var element = document.SelectSingleNode("/RuleSet/@Name");
        //        var name = (element != null) ? element.Value : Path.GetFileNameWithoutExtension(path);
        //        AddOptionItem(name, path, isCustom);
        //    }
        //    catch (Exception e)
        //    {
        //        Logger.Error(String.Format("Failed to get RuleSet name of '{0}'.", path), e);
        //    }
        //}

        //private void AddOptionItem(string name, string path, bool isCustom)
        //{
        //    var item = new RuleSetOptionItem();
        //    item.Name = name;
        //    item.Value = String.Format("{0};{1}", (isCustom)? "Custom":"Bundled",  Path.GetFileName(path));
        //    RuleSetOptionItems.Add(item);
        //}
        
        //private void OnSelectionOptionValueChanged(object sender, SelectionChangedEventArgs e)
        //{
        //    if (e.OriginalSource is ComboBox)
        //    {
        //        var comboBox = (ComboBox)e.OriginalSource;
        //        var item = e.AddedItems[0] as ISelectionOptionItem;
        //        if (item.Name == "<New>")
        //        {
        //            // TODO: implement
        //        }
        //        else if (item.Name == "<Browse>")
        //        {
        //            // TODO: implement
        //        }
        //    }
        //}
    }
}
